import requests
import re

url = "https://www.sanchuangedu.cn"
r = requests.get(url)
pic_url = re.findall(r'<img src="(.*(?:jpg|png))', r.text)
i = 0
for key in pic_url:
    pi = url + key
    print("开始下载图片：" + pi + "\r\n")
    try:
        pic = requests.get(url + key, timeout=10)
    except requests.exceptions.ConnectionError:
        print("图片无法下载")
        continue
    di = "C:\\Users\\Admin\\Desktop\\re\\" + str(i) + '.jpg'
    with open(di, 'wb') as fp:
        fp.write(pic.content)
    i += 1
